package com.franklin.ideaplugin.easytesting.ui.history;

import com.franklin.ideaplugin.api.ui.tree.BaseSimpleNode;
import com.intellij.ui.tree.BaseTreeModel;

import java.util.Collections;
import java.util.List;

/**
 * 历史书model
 *
 * @author Ye Junhui
 * @since 2023/6/21
 */
public class ExecuteHistoryTreeModel extends BaseTreeModel<BaseSimpleNode> {

    private final MethodNode methodNode;
    private final List<HistoryNode> historyNodeList;

    public ExecuteHistoryTreeModel(MethodNode methodNode, List<HistoryNode> historyNodeList) {
        this.methodNode = methodNode;
        this.historyNodeList = historyNodeList;
    }

    @Override
    public List<? extends BaseSimpleNode> getChildren(Object parent) {
        if (parent instanceof HistoryNode){
            return Collections.emptyList();
        }
        this.methodNode.setChildrenNodeList(this.historyNodeList);
        return this.historyNodeList;
    }

    @Override
    public Object getRoot() {
        return this.methodNode;
    }

}
